package com.yztc.ui.home.adapter;

import android.support.v4.view.PagerAdapter;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import java.util.List;

/**
 * Created by My on 2016/10/8.
 */
public class HomePageAdapter extends PagerAdapter {
    private List<ImageView> imageViews;
    public HomePageAdapter( List<ImageView> imageViews){
        this.imageViews = imageViews;
    }
    @Override
    public int getCount() {
        return Integer.MAX_VALUE;
    }

    @Override
    public boolean isViewFromObject(View view, Object object) {
        return view == object;
    }

    @Override
    public Object instantiateItem(ViewGroup container, int position) {
        container.addView(imageViews.get(position%imageViews.size()));
        return imageViews.get(position%imageViews.size());
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
        container.removeView(imageViews.get(position%imageViews.size()));
    }
}
